{extend name="base" /} {block name="body"}
<div class="layui-body">
	<div class="navbar">
		<a><cite>广告管理</cite></a>&nbsp;<span class="layui-box">&gt;</span>
		<a href=""><cite>添加广告</cite></a>
	</div>
	<!--tab标签-->
	<div class="layui-tab layui-tab-card margin10">
		<ul class="layui-tab-title">
			<li class="layui-this">添加广告</li>
		</ul>
		<div class="layui-tab-content">
			<form class="layui-form form-container layui-form-pane" action="" method="post">
				<div class="layui-form-item">
					<label class="layui-form-label">标题</label>
					<div class="layui-input-block">
						<input type="text" name="title" lay-verify="required" placeholder="请输入标题" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">超链接</label>
					<div class="layui-input-block">
						<input type="text" name="url" lay-verify="required" placeholder="请输入广告链接" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">广告类型</label>
					<div class="layui-input-block">
						<select name="type" lay-verify="required">
							<option value="1">首页广告</option>
							<option value="2">健康广告</option>
							<option value="3">商城广告</option>
							<option value="4">其它广告</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">广告图</label>
					<div class="layui-input-block" style="padding-left: 10px;">
						<div class="layui-upload">
							<button type="button" class="layui-btn" id="image">上传图片</button>
							<div class="layui-upload-list">
								<img class="layui-upload-img" style="width: 150px;height: 150px;" id="demo1">
								<p id="demoText"></p>
							</div>
						</div>
					</div>
				</div>
				<input type="hidden" name="thumb" id="thumb"/>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter="*"><i class="fa fa-save"></i> 保存</button>
						<a href="{:url('ads')}" class="layui-btn layui-btn-primary"><i class="fa fa-arrow-left"></i> 返回</a>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
{/block} {block name="js"}
<script>
		var GV = {
					current_controller: "ads/ads"
		};
	layui.use('upload', function() {
		var upload = layui.upload,
		jq = layui.jquery;
		upload.render({
			url: '{:url("upload")}',
			elem: '#image',
			ext: 'jpg|png|gif',
			area: ['500', '500px'],
			before: function(input) {
				
			},
			done: function(res) {
				if(res.code==1){
					$("#demo1").attr('src',res.src);
					$("#thumb").val(res.src);
				}
			}
		});

	})
</script>
{/block}